Clover coverage report - Flock Flock - 0.7-dev
Coverage timestamp: Thu Jan 30 2003 01:35:37 EST
file stats: LOC: 111   Methods: 11
NCLOC: 84   Classes: 1
This license of Clover is provided to support the development of Flock only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover.
 
 Source file Conditionals Statements Methods TOTAL
HibernateSubscriptionManager.java 0% 61.3% 27.3% 50%
 1   
 package net.sf.flock.hibernate;
 2   
 
 3   
 import java.net.URL;
 4   
 import java.util.Collection;
 5   
 import java.util.List;
 6   
 import java.util.Properties;
 7   
 
 8   
 import net.sf.flock.FeedFactoryI;
 9   
 import net.sf.flock.FeedI;
 10   
 import net.sf.flock.FilterI;
 11   
 import net.sf.flock.FlockResourceException;
 12   
 import net.sf.flock.SubscriptionI;
 13   
 import net.sf.flock.SubscriptionInfoI;
 14   
 import net.sf.flock.support.AbstractSubscriptionManager;
 15   
 import cirrus.hibernate.Datastore;
 16   
 import cirrus.hibernate.Hibernate;
 17   
 import cirrus.hibernate.HibernateException;
 18   
 import cirrus.hibernate.MappingException;
 19   
 import cirrus.hibernate.Session;
 20   
 import cirrus.hibernate.SessionFactory;
 21   
 import cirrus.hibernate.Transaction;
 22   
 import cirrus.hibernate.tools.SchemaExport;
 23   
 
 24   
 public class HibernateSubscriptionManager extends AbstractSubscriptionManager implements FeedFactoryI {
 25   
     
 26   
     private final SessionFactory sessionFactory;
 27   
 
 28  1
     public HibernateSubscriptionManager(Properties properties) throws FlockResourceException {
 29   
 
 30  1
         try {
 31   
             
 32  1
             properties.put("hibernate.query.imports", "net.sf.flock.hibernate");
 33   
             
 34  1
             Datastore ds = Hibernate.createDatastore();
 35  1
             ds.storeClass( Subscription.class );
 36   
             
 37  1
             new SchemaExport(ds, properties).create(true, true);
 38   
             //new SchemaUpdater(ds, properties).execute(false);
 39   
 
 40  1
             this.sessionFactory = ds.buildSessionFactory(properties);
 41   
         } catch (MappingException e) {
 42  0
             throw new FlockResourceException(e);
 43   
         } catch (HibernateException e) {
 44  0
             throw new FlockResourceException(e);
 45   
         }        
 46   
     }
 47   
 
 48  1
     protected void storeSubscription(Subscription subscription) throws Exception {
 49  1
         Session s = this.sessionFactory.openSession();
 50   
         
 51  1
         Transaction tx = null;
 52  1
         try {
 53  1
             tx = s.beginTransaction();
 54   
             //s.save(subscription.getFeed());
 55  1
             s.save(subscription);
 56  1
             s.flush();
 57  1
             tx.commit();
 58   
         } catch (Exception ex) {
 59  0
             if (tx!=null) tx.rollback();
 60  0
             throw ex;
 61   
         } finally {
 62  1
             s.close();
 63   
         }
 64   
     }
 65   
 
 66  1
     protected Subscription loadSubscription(URL url) throws Exception {
 67  1
         Session s = this.sessionFactory.openSession();
 68   
         
 69  1
         try {
 70  1
             List l = s.find("from sub in class Subscription where location=?", url, Hibernate.custom(URLType.class));
 71  1
             return (Subscription)l.get(0);
 72   
         } catch (Exception ex) {
 73  0
             throw ex;
 74   
         } finally {
 75  1
             s.close();
 76   
         }
 77   
     }
 78   
 
 79  0
     protected SubscriptionI createSubscription(SubscriptionInfoI subscriptionInfo) throws FlockResourceException {
 80  0
         return null;
 81   
     }
 82   
 
 83  0
     protected FeedFactoryI getFeedFactory() {
 84  0
         return this;
 85   
     }
 86   
 
 87  0
     public FeedI createFeed(SubscriptionInfoI subscriptionInfoI) {
 88  0
         return null;
 89   
     }
 90   
 
 91  0
     public void unsubscribe(URL url) throws FlockResourceException {
 92   
     }
 93   
 
 94  0
     public SubscriptionI getSubscription(URL url) throws FlockResourceException {
 95  0
         return null;
 96   
     }
 97   
 
 98  0
     public Collection getSubscriptionInfos() throws FlockResourceException {
 99  0
         return null;
 100   
     }
 101   
 
 102  0
     public void refresh(URL url) throws FlockResourceException {
 103   
     }
 104   
 
 105  0
     public Collection findItems(FilterI[] filters) throws FlockResourceException {
 106  0
         return null;
 107   
     }
 108   
 
 109   
 
 110   
 }
 111